06. Working with Objects

Working with Objects

ND079 C1 L2 A07a Working With Objects-Calculator Example

title

As we've covered before, one of Java's key characteristics is that it is object-oriented. This means operations are performed on objects and not directly on variables. In this paradigm, we start by creating our classes first, which contain the behavioral logic necessary to perform our operations.

We define the class by:

  • Giving it a name
  • Setting up the instance variables (states)
  • Initializing our instance variables within the constructor
  • Defining the methods (behavior)

After writing our code, we are ready to test. To run the test, we create a Driver or Tester class. This is a class that has a main method. (Remember, the main method in Java is a special method and is the entry point to executing code.)

This can all seem very abstract, so next we will walk through an exercise where you'll get some practice working with objects in Java.